home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Spanish Scene 1
/
SpanishScene1.iso
/
spanish pack n°1 by llfb
/
--llfb--
/
programas
/
sources1.dms
/
sources1.adf
/
SOURCES
/
Vectores
/
PolyDraw.ASM
< prev
next >
Wrap
Assembly Source File
|
1996-06-04
|
7KB
|
345 lines
; *** This routine draws a polygon, using the blitter, and fills
; it with flood fill afterwards!
; This version is really bugged....
; [1] Use blitter logic to remove "double" points (type:xor)
; [2] Logic fill... Not entire screen, but only top-bottom
; [3] Copy to different bitplanes for colours
; [4] Patterns as well (?) - Type Stencil Polygons
; [5] Shoot me or I'll blow myself to P.C.S.
; *** Done by Tee Djay of PowerLords 03.07.1990
Section Roman,code_c
start: move.l 4,a6
jsr -132(a6) ; forbid multitasking
move.w $dff01c,old_intena
ori.w #$8000,old_intena
move.w #$03fdf,$dff09a ; only vblank interrupt
move.w #$7fff,$dff096
bsr.L clr_sprites
bsr.L set_bitplanes
bsr.L make_sin_tab
move.l #copper,$dff080
clr.w $dff088
move.w #$83ff,$dff096
main_loop: cmp.b #250,$dff006
bne.s main_loop
move.l screen,d0
move.w d0,bpls+6
swap d0
move.w d0,bpls+2
move.l screen,d0
move.l scree2,screen
move.l d0,scree2
add.w #6,angle
and.w #510,angle
lea sincos,a0
lea coords,a1
lea polygon,a2
move.w #8-1,d2
ml01: move.w angle,d0
move.w d0,d1
add.w #128,d1
and.w #510,d0
and.w #510,d1
move.w (a0,d0.w),d0
move.w (a0,d1.w),d1
move.w (a1)+,d4
move.w (a1)+,d5
move.w d4,d6
move.w d5,d7
muls d1,d4
muls d0,d5
muls d0,d6
muls d1,d7
swap d4
swap d5
swap d6
swap d7
sub.w d5,d4
add.w d7,d6
add.w #160,d4
add.w #100,d6
move.w d4,(a2)+
move.w d6,(a2)+
dbra d2,ml01
move.l screen,a0
move.w #1999,d0
ml02: clr.l (a0)+
dbra d0,ml02
lea polygon,a0
moveq #0,d7
bsr.L draw_polygon ; 1st polygon
; lea polygon,a0
; bsr plot_points
; bsr plot_points
bsr.L fill_polygon
bsr.L remove_zigs
lea polygon+16,a0
move.w #2,d7
bsr.L draw_polygon ; 2nd polygon
btst #6,$bfe001
bne.L main_loop
end: bsr.s wait_blit
move.l 4,a6
move.l #grname,a1
clr.l d0
jsr -552(a6)
move.l d0,a4
move.l 38(a4),$dff080
clr.w $dff088
move.w #$83e0,$dff096
move.w old_intena,$dff09a
jsr -138(a6) ; enable multitasking
clr.l d0
rts
old_intena: dc.w 0
wait_blit: btst #14,$dff002
bne.s wait_blit
rts
set_bitplanes: move.l screen,d0
lea bpls,a0
moveq #3,d1
set_bpl_pnt: move.w d0,6(a0)
swap d0
move.w d0,2(a0)
swap d0
add #40,d0
addq #8,a0
dbra d1,set_bpl_pnt
rts
clr_sprites: lea copspr,a0
move.l #$0120,d0
move.l #7,d1
cl_spr_pnt: move.w d0,(a0)+
clr.w (a0)+
add.w #2,d0
move.w d0,(a0)+
clr.w (a0)+
add.w #2,d0
dbra d1,cl_spr_pnt
rts
Draw_Line: movem.l d0-d7/a0-a6,-(a7)
cmp.w d0,d2
bne.s dl00
cmp.w d1,d3
beq.L end_line
dl00: cmp.w #319,d0
bhi.L end_line
cmp.w #319,d2
bhi.L end_line
cmp.w #199,d1
bhi.L end_line
cmp.w #199,d3
bhi.L end_line
cmp.w d1,d3
bge.s dl10
exg d2,d0
exg d3,d1
dl10: move.w d2,d4
sub.w d0,d4
bmi.s dl11
neg.w d4
dl11: move.w d1,d5
sub.w d3,d5
beq.s dl12
lsl.w #1,d5
cmp.w d4,d5
blt.s dl12
subq #1,d3
dl12:
move.l screen,a0 ; Start of screen
move.w #40,a1 ; Width of screen (bytes)
move.w a1,d4
mulu d1,d4
moveq #-16,d5
and.w d0,d5
lsr.w #3,d5
add.w d5,d4
add.l a0,d4
moveq #0,d5
sub.w d1,d3 ; Delta Y
roxl.b #1,d5
tst.w d3
bge.s y2gy1
neg.w d3
y2gy1: sub.w d0,d2 ; Delta X
roxl.b #1,d5
tst.w d2
bge.s x2gx1
neg.w d2
x2gx1: move.w d3,d1
sub.w d2,d1 ; DeltaY-DeltaX
bge.s dygdx
exg d2,d3
dygdx: roxl.b #1,d5
add.w d2,d2 ; Smallest Delta*2
bsr.L wait_blit
move.w d2,$dff062 ; bltbmod
move.b okttabelle(pc,d5),d5
sub.w d7,d5
sub.w d3,d2
bge.s signnl
ori.b #$40,d5
signnl: move.w d2,$dff052 ; bltaptl
sub.w d3,d2
move.w d2,$dff064 ; bltamod
move.w #$8000,$dff074 ; bltadat
move.w #-1,$dff072 ; bltbdat
move.w #-1,$dff044 ; bltafwm
andi.w #15,d0
ror.w #4,d0
or.w #$0bca,d0
move.w d0,$dff040 ; bltcon0
move.w d5,$dff042 ; bltcon1
move.l d4,$dff048 ; bltcpth
move.l d4,$dff054 ; bltdpth
move.w a1,$dff060 ; bltcmod
move.w a1,$dff066 ; bltdmod
lsl.w #6,d3
addq.w #2,d3
move.w d3,$dff058 ; bltsize
end_line: movem.l (a7)+,d0-d7/a0-a6
rts
okttabelle: dc.b 3,19,11,23,7,27,15,31
make_sin_tab: lea sincos,a1
lea sincos+512,a2
move.w #63,d0
msl02: move.w (a1)+,(a2)+
dbra d0,msl02
lea sincos+128,a0
lea sincos+128,a1
move.w #63,d0
msl00: move.w -(a0),(a1)+
dbra d0,msl00
move.w #127,d0
msl01: move.w (a0)+,d1
neg.w d1
move.w d1,(a1)+
dbra d0,msl01
rts
sincos: dc.w 00000,00804,01607,02410,03211,04011
dc.w 04808,05602,06392,07179,07961,08739
dc.w 09512,10278,11039,11793,12539,13278
dc.w 14010,14732,15446,16151,16846,17530
dc.w 18204,18868,19519,20159,20787,21403
dc.w 22005,22594,23170,23732,24279,24812
dc.w 25330,25832,26319,26790,27245,27684
dc.w 28106,28511,28898,29269,29621,29956
dc.w 30273,30572,30852,31114,31357,31581
dc.w 31785,31971,32138,32285,32413,32521
dc.w 32610,32679,32728,32758
blk.b 512,0
grname: dc.b "graphics.library",0,0
copper: dc.w $008e,$4081,$0090,$08c1
dc.w $0092,$0038,$0094,$00d0
dc.w $0102,$0000,$0104,$0000
dc.w $0108,$0000,$010a,$0000
dc.w $0100,$1200
dc.w $0180,$0000,$0182,$0fff
copspr: blk.b 64,0
bpls: dc.w $00e0,$0000,$00e2,$0000
dc.w $00e4,$0000,$00e6,$0000
dc.w $00e8,$0000,$00ea,$0000
dc.w $00ec,$0000,$00ee,$0000
dc.w $ffff,$fffe
scr_buffer: blk.b 2*8000,0
screen: dc.l scr_buffer
scree2: dc.l scr_buffer+8000
angle: dc.w 32
polypos: dc.w 0,0 ; Top left corner
polyblitsize: dc.w 0,0 ; length/width
polygon: blk.b 32,0
coords: dc.w -90,-90,-20,-90,-20,-20,-90,-20
dc.w 090,-90,090,090,-90,090,-90,90
; *** NOTE! Coordinates for a polygon - the specific order!
draw_polygon: move.w (a0)+,d0
move.w (a0)+,d1
move.w (a0)+,d2
move.w (a0)+,d3
bsr.L draw_line
move.w (a0)+,d0
move.w (a0)+,d1
bsr.L draw_line
move.w (a0)+,d2
move.w (a0)+,d3
bsr.L draw_line
move.w -16(a0),d0
move.w -14(a0),d1
bsr.L draw_line
rts
fill_polygon: bsr.L wait_blit
move.l screen,d0
add.l #7998,d0
move.l d0,$dff054
move.l d0,$dff050
move.l #$09f0000a,$dff040
move.l #-1,$dff044
move.l #0,$dff064
move.w #64*200+20,$dff058
rts
remove_zigs: move.l screen,a0
adda.l #7960,a0
bsr.L wait_blit
move.w #199,d0
rz00: tst.w (a0)
beq.s rz01
move.l a0,a1
move.w #9,d1
rz02: clr.l (a1)+
dbra d1,rz02
rz01: suba.l #40,a0
dbra d0,rz00
rts
plot_points: move.w #3,d2
pp00: move.w (a0)+,d0
move.w (a0)+,d1
mulu #40,d1
move.w d0,d3
and.w #7,d3
lsr.w #3,d0
add.w d0,d1
add.l screen,d1
move.l d1,a1
neg d3
add.w #7,d3
bset d3,(a1)
dbra d2,pp00
rts